#ifndef _KSMG_PR_H_
#define _KSMG_PR_H_

#include <linux/module.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <share.h>

struct kmsg_node;
typedef int (kmsg_end_msg_t) (struct kmsg_node *, int, int);

typedef struct kmsg_node {
	atomic_t ref_cnt;
	struct list_head list;
	kmsg_msg_t *msg;
	kmsg_end_msg_t *end_msg;
	void *priv_data;
} kmsg_node_t;

/*-------------------------------------
 * for others
 -------------------------------------*/

#define mem_clear(p, size)              \
do{                                     \
	memset((p), 0x88, (size));          \
}while(0)

#define X_ASSERT(assert) 			\
	do { 					\
		if (unlikely(!(assert))) { 	\
			printk(KERN_EMERG ": Assertion failure in %s() at %s:%d: \"%s\"\n", 	\
					__FUNCTION__, __FILE__, __LINE__, # assert); 		\
			mdelay(15000); 		\
			BUG(); 			\
		} 				\
	} while (0)


#ifdef __ENABLE_DEBUG__ 

#define DEBUG(fmt, argv...) 				\
do { 							\
	printk(KERN_ERR "[KSMG]::%d:%s:%s:%d::"fmt"\n", \
		current->pid, __FUNCTION__, 		\
		(strrchr(__FILE__, '/') + 1), 		\
		__LINE__, ##argv); 			\
} while (0)

#define DEBUG_FN(fn) (fn)
#define ENTER DEBUG("__ENTER__")
#define LEAVE DEBUG("__LEAVE__")
#define TRACE DEBUG("__TRACE__")

#else

#define DEBUG(fmt, argv...)
#define DEBUG_FN(fn)
#define ENTER(argv...)
#define LEAVE(argv...)
#define TRACE(argv...)

#endif

#define KMSG_ERR(fmt, argv...) 				\
do { 							\
	printk(KERN_ERR "[KSMG]::"fmt"\n", ##argv);	\
} while (0)

#endif
